//
//  ViewController.m
//  Qbutton
//
//  Created by CHENGXIANG QIU on 2018/6/14.
//  Copyright © 2018年 CHENGXIANG QIU. All rights reserved.
//

#import "ViewController.h"
#import "Mybtn.h"
#import "subViewController.h"
#import "Header/HeaderNavBar.h"
#import "Header/TableViewController.h"

@interface ViewController ()<UIScrollViewDelegate>
@property (nonatomic, weak) UIView *headerView;
@property (nonatomic, strong) UIButton *editButton;
@end

@implementation ViewController

- (void)viewDidLoad {
    self.view.backgroundColor = [UIColor whiteColor];
    [super viewDidLoad];
    [self createBtn];
}

- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
    
}
-(void) createBtn{
    Mybtn *btn = [[Mybtn alloc]initWithFrame:CGRectMake(20, 100, 100, 30)];
    btn.backgroundColor = [UIColor grayColor];
    NSString *btnTitle = @"我的按钮";
    [btn setTitle:btnTitle forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}
-(void) btnAction{
    [super self];
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Information:" message:@"You clicked me!" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                            handler:^(UIAlertAction * action) {
            TableViewController *secondVC = [[TableViewController alloc]init];
//              [self openURL:@"http://www.baidu.com"];
                [self.navigationController  presentViewController:secondVC animated:YES completion:^{}];
       }];
    
    [alert addAction:defaultAction];
    [self presentViewController:alert animated:YES completion:nil];
};
-(void)openURL:(NSString*)requestUrl{
    UIWebView *webview = [[UIWebView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.view = webview;
    NSURL *URL = [NSURL URLWithString:requestUrl];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];
    [webview loadRequest:request];
}
@end
